import axios from 'axios'
// import { reject } from 'core-js/fn/promise'
axios.defaults.baseURL = "/xiaochengxu"

axios.interceptors.request.use(config => {
    return config
}, error => {
    return reject(error)
})

axios.interceptors.response.use(response => {
    return response.data;
}, error => {
    return reject(error)
})

export const get = (url, data) => {
    return new Promise((reslove, reject) => [
        axios.get(url, data).then(res => {
            reslove(res)
        }, err => {
            reject(err)
        })
    ])
}

export const post = (url, data = {}) => {
    return new Promise((reslove, reject) => [
        axios.post(url, data).then(res => {
            reslove(res)
        }, err => {
            reject(err)
        })
    ])
}